home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1993 December / PSL Monthly Shareware CD-ROM (December 1993).iso / prgmming / win / general / wsheap.exe / WSHEAP.PAS < prev    next >
Pascal/Delphi Source File  |  1993-02-01  |  3KB  |  66 lines

  1. {*********************************************************}
  2. {*                   WSHEAP.PAS 1.01                     *}
  3. {*       Copyright (c) TurboPower Software 1993.         *}
  4. {*                 All rights reserved.                  *}
  5. {*********************************************************}
  6.  
  7. unit WsHeap;
  8.   {-Import unit for WSHEAP.DLL}
  9.  
  10. interface
  11.  
  12. const
  13.   {Masks to enable suballocator analysis}
  14.   sfNone = $0000;             {no suballocators}
  15.   sfTPW  = $0001;             {TPW heap block}
  16.   sfLH   = $0002;             {Local heap block}
  17.   sfBC   = $0004;             {BC heap block}
  18.   sfMSC  = $0008;             {MSC heap block}
  19.   sfAll  = $FFFF;             {all available suballocators}
  20.  
  21. type
  22.   TFlatArray =                {16 bytes}
  23.     record                    {manages a 1D contiguous array of elements}
  24.       aHandle   : Word;       {handle of memory block}
  25.       aSel      : Word;       {selector of memory block}
  26.       aCount    : LongInt;    {current element count}
  27.       aCapacity : LongInt;    {current element capacity}
  28.       aElSize   : Word;       {element size; must be power of two}
  29.       aElGrow   : Word;       {number of elements to grow when needed}
  30.     end;
  31.  
  32.   THeapState =                {34 bytes}
  33.     record                    {descriptor for saved heap state}
  34.       hGlobal   : TFlatArray; {global blocks}
  35.       hSub      : TFlatArray; {suballocator blocks}
  36.       hSubFlags : Word;       {enabled suballocators}
  37.     end;
  38.  
  39.   function SaveHeapState(var HS : THeapState; SubFlags : Word) : Word;
  40.     {-Save current heap state, returning 0 if successful}
  41.  
  42.   function CompareHeapState(var HS : THeapState;
  43.                             DumpFileName : PChar;
  44.                             DumpMsg : PChar) : Word;
  45.     {-Compare current heap state to saved state, returning status code}
  46.  
  47.   procedure DoneHeapState(var HS : THeapState);
  48.     {-Dispose of saved heap state}
  49.  
  50.   {Status codes returned by SaveHeapState and CompareHeapState:
  51.           0      success
  52.           8      insufficient memory
  53.        8051      invalid FlatArray element size (internal error)
  54.        8054      GlobalLock failure
  55.        8500      local heap entries not in ascending order
  56.        else      Turbo Pascal I/O result code
  57.   }
  58.  
  59. implementation
  60.  
  61.   function SaveHeapState;      external 'WSHEAP' index 1;
  62.   function CompareHeapState;   external 'WSHEAP' index 2;
  63.   procedure DoneHeapState;     external 'WSHEAP' index 3;
  64.  
  65. end.
  66.